<?php

/**
 * Course form base class.
 *
 * @method Course getObject() Returns the current form's model object
 *
 * @package    makethetouch
 * @subpackage form
 * @author     Sebastien Chassande-Barrioz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseCourseForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'idcourse'     => new sfWidgetFormInputHidden(),
      'type'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CourseType'), 'add_empty' => false)),
      'venue'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Address'), 'add_empty' => false)),
      'begin_date'   => new sfWidgetFormDate(),
      'end_date'     => new sfWidgetFormDate(),
      'teacher'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Person'), 'add_empty' => false)),
      'fee'          => new sfWidgetFormInputText(),
      'max_students' => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'idcourse'     => new sfValidatorChoice(array('choices' => array($this->getObject()->get('idcourse')), 'empty_value' => $this->getObject()->get('idcourse'), 'required' => false)),
      'type'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('CourseType'))),
      'venue'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Address'))),
      'begin_date'   => new sfValidatorDate(),
      'end_date'     => new sfValidatorDate(),
      'teacher'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Person'))),
      'fee'          => new sfValidatorNumber(array('required' => false)),
      'max_students' => new sfValidatorInteger(),
    ));

    $this->widgetSchema->setNameFormat('course[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Course';
  }

}
